<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
    <title><spring:message code="title.ipic.target"/></title>
      <style type="text/css">
        .font_stress{
            color: red;font-size: 13px;font-weight:bold;
        }
    </style>
    <script type="text/javascript">
         var operateDialog;
          var datagrid;
	        $(function() {
	            datagrid=$('#datagrid').datagrid({
	                onClickRow:function(rowIndex){
	                    var rows = datagrid.datagrid('getRows');
	                    for ( var i = 0; i < rows.length; i++) {
	                        datagrid.datagrid('endEdit', i);
	                    }
	                    datagrid.datagrid('beginEdit', rowIndex);
	                }
	            });
	            
	            
	        });
	        
	       function save_(){
	       
	        if($("#supplierCode").val()==''){
               $.messager.alert('提示','供应商不能为空');
                 return;
            }  
	       
	       
	       var objName= document.getElementById("chk_updateRequireds");
	       var obj= document.getElementById("selfAssessments");
	       
	        var values= $('#values').numberbox('getValue');
	        
	        if(values==''){
	        		 $.messager.alert('<spring:message code='msg.tip'/>','得分不能为空!');
		            return;
	        }
	        
	        var comments=$('#comments').val(); 
	       
	        var value = $("input[name='xx'][type='radio']:checked").val();
	        
	         var v2 =$("#expireDate1").val();
	         
	          var v3 =$("#selfAssessmentDate").val();
	          
	         var v4=$('#contactPersons').val(); 
	         var v5;
	         if(selfAssessments.checked){
	           	v5=1;
	         }else{
	            v5=0;
	         }
	        if(value==1){
	        
			    var v1 =$("#certificationDate1").val();
		       if(v1==''){
		            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
		            return;
		       }
		       if(v2==''){
		          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
		          return;
		       }
		       
		       if(objName.checked){
     	          $('#updateRequired').val("1");
		       }else{
		          $('#updateRequired').val("0");
		       }
			     $('#certificationType').val(value);
			     $('#certificationDate').val(v1);
			     $('#expiredDate').val(v2);
			     
			     
	        }else if(value==2){
	           var v1=$('#certificationDate2').val(); 
		       if(v1==''){
		            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
		            return;
		       }
		       if(v2==''){
		          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
		          return;
		       }
		       
		       if(objName.checked){
     	          $('#updateRequired').val("1");
		       }else{
		          $('#updateRequired').val("0");
		       }
			     $('#certificationType').val(value);
			     $('#certificationDate').val(v1);
			     $('#expiredDate').val(v2);  
	           
	        }else if(value==3){
	       		 var v1=$('#certificationDate3').val(); 
			       if(v1==''){
			            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
			            return;
			       }
			       if(v2==''){
			          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
			          return;
			       }
			       
			       if(objName.checked){
	     	          $('#updateRequired').val("1");
			       }else{
			          $('#updateRequired').val("0");
			       }
				     $('#certificationType').val(value);
				     $('#certificationDate').val(v1);
				     $('#expiredDate').val(v2);  
	        }else{
	        		 $('#certificationType').val(value); 
	        	
	        }
	          $('#selfAssessmentDates').val(v3);    
		     $('#contactPerson').val(v4);  
		     $('#selfAssessment').val(v5);
	        $('#comment').val(comments); 
			$('#value').val(values); 
	      
	        var isV =$("#tableForm").form("validate");
            if(!isV) return; 
            
            imonJYRH.showZone();
            var effectData = new Object();
            effectData["qualitySystem"] =  JSON.stringify(imonJYRH.serializeObject($("#tableForm *")));
            
            $.ajax({
                url : '${path}/business/supplier_quality/quality_system/ajaxAdd.do',
                 data : effectData,
                 cache : false,
                 async : true,
                 dataType : "json",
                success : function(reMsg) {
                    if(reMsg.success){
                        parent.returnResult();
                        message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                        if(!imonJYRH.isBlank(reMsg.obj)){
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                        }else{
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                        }
                    }
                    imonJYRH.hideZone();
                }
            });
        }
      function envValue(values){
          if(values==1){
           $('#values').numberbox('setValue',10);
            $('#certificationDate2').val(null);
            $('#certificationDate3').val(null);
          }else if(values==2){
           $('#values').numberbox('setValue',8);
            $('#certificationDate1').val(null);
            $('#certificationDate3').val(null);
          }else if(values==3){
            $('#certificationDate1').val(null);
            $('#certificationDate2').val(null);
           $('#values').numberbox('setValue',0);
          }else{
           $('#certificationDate1').val(null);
            $('#certificationDate2').val(null);
             $('#certificationDate3').val(null);
             $('#expireDate1').val(null);
           $('#values').numberbox('setValue',0);
          }
       }
       
       function dialogSupplier_(){
            var href = '${path}/basedata/supplier/dialogUI.do';
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 650,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
     function dialogSupplierReturn(row){
            $("#supplierId").val(row['id']);
            $("#supplierCode").val(row['code']);
            $("#supplierName").val(row['name']);
            operateDialog.dialog('close');
        }
    </script>
</head>
 <body class="easyui-layout">
<div data-options="region:'center'">
    <div class="datagrid-toolbar" style="height:480px">
       <table width="100%" id="tableForm">
                <tr>
                    <td align="right">SupplierCode供应商编码：</td>
                    <td>
                       	<input type="hidden" id='supplierId' name="supplierId"/>
                             <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true"/>
                    </td>
                    <td align="right">SupplierName供应商名称：</td>
                    <td>
                         <input type="text" id="supplierName" style="width: 180px;" disabled/>
                    </td>
                   <!-- <td align="right">Supplier Type供应商类型：</td>
                    <td>
                        <input type="text"  name="type" disabled/>
                    </td>-->
                     <input type="hidden"  name="certificationType" id="certificationType"/>
                     <input type="hidden"  name="certificationDates" id="certificationDate"/>
                     <input type="hidden"  name="expiredDates" id="expiredDate"/>
                     <input type="hidden"  name="updateRequired" id="updateRequired"/>
                     <input type="hidden"  name="value" id="value"/>
                     <input type="hidden"  name="comment" id="comment"/>
                     <input type="hidden"  name="selfAssessment" id="selfAssessment"/>
                     <input type="hidden"  name="contactPerson" id="contactPerson"/>
                     <input type="hidden"  name="selfAssessmentDates" id="selfAssessmentDates"/>
                </tr>
            </table>

        <br/>
        <div class="font_stress" align="center">
            QM-System(10 POINTS)
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Evaluation Value：
            <input type="text" id="values" class="easyui-numberbox" data-options="required:true" value="10" readonly="true"/>
        </div>
        <br/>
        <hr width="800px"/>
        <table>
            <tr>
                <td width="550px">
                    <table width="100%">
                        <tr>
                            <td align="right"></td>
                            <td></td>
                            <td><label style="font-weight:bold;">Certification Date</label></td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_1">TS16949 认证<br/>TS16949registered</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_1" value="1" checked="true"  onclick="envValue(1)">
                            </td>
                            <td>
                                <input type="text"   id="certificationDate1"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_2">DIN ISO 9001 认证<br/>DIN ISO 9001 registered</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_2" value="2" onclick="envValue(2)">
                            </td>
                            <td>
                                <input type="text"   id="certificationDate2"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_3">低于DIN ISO 9001的认证，<br/>供应商不允许交付到上海爱德夏<br/>worse than DIN ISO 9001 is ko criteria, <br/>supplier is not allowed to deliver to SEM</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_3" value="3" onclick="envValue(3)">
                            </td>
                            <td>
                                <input type="text"   id="certificationDate3"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label for="radio_4">No certified</label>
                            </td>
                            <td>
                                <input type="radio" style="width: 10px;" name="xx" id="radio_4" value="4" onclick="envValue(4)">
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="180px">
                    <table width="100%">
                        <tr>
                            <td>
                                <table width="100%">
                                    <thead>
                                    <tr>
                                        <th>Expire Date of Certificate：</th>
                                    </tr>
                                    <tr>
                                        <th><input type="text"  id="expireDate1"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/></th>
                                    </tr>
                                    </thead>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="chk_updateRequired">Update Required</label>
                                <input id="chk_updateRequireds" type="checkbox" style="width: 10px;"/>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <br />
        <hr width="800px"/>
        <table width="100%" style="text-align: center">
            <tr>
                <td width="50px"></td>
                <td>
                    <label for="chk_selfAssessment">Self Assessment</label>
                    <input  type="checkbox" style="width: 10px;" id="selfAssessments"/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Contact Person：
                    <input type="text" id="contactPersons"/>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    Date of self assessment：
                    <input type="text"   id="selfAssessmentDate"  onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                </td>
            </tr>
        </table>
        <br />
        <hr width="800px"/>
        <table width="100%">
            <tr>
                <td width="200px"></td>
                <td align="right">
                    Comment评论：
                </td>
                <td>
                    <textarea rows="3" cols="40" id="comments"></textarea>
                </td>
            </tr>
        </table>
        <br />
        <div align="right">
              <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-save" onclick="save_();"><spring:message code='button.save'/></a>
              <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-no" onclick="parent.operateDialog.dialog('close');"><spring:message code='button.close'/></a>
        </div>
    </div>
</div> 
	<div id="operateDialog" class="easyui-dialog"
		style="width:880px;height:520px;"
		data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
		<iframe scrolling="auto" id='operateIFrame' frameborder="0" src=""
			style="width:100%;height:100%;" />
	</div>
</body> 
</html>